<template>
  <div id="ClosingTimeConfiguration">
    <h4>停业时间配置</h4>
    <div class="content">
      <p v-if="!value2">请设置停业的时间段，该时间段内用户不可预约</p>
      <p v-else>停业时间：{{value2[0] | timeFn}}～{{value2[1] | timeFn}}</p>
    <el-date-picker
      v-model="value"
      type="datetimerange"
      range-separator="至"
      start-placeholder="开始日期"
      end-placeholder="结束日期">
    </el-date-picker>
      <el-button type="primary" @click="editFn">确认修改</el-button>
      <div v-if="value2!=null">该时间段内已有预约用户，请先取消所有订单</div>
      <div v-else>如何删除停业时间的设定：直接点击确认修改即可</div>
      <div>
        <el-link type="primary" v-if="value2!=null" @click="orderFn">查看预约订单</el-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data:function() {
    return {
      value: [new Date('2016-9-10 8:40:00'), new Date(2016, 9, 10, 9, 40)],
      value2:null
    };
  },
  filters:{
    timeFn:function(time){
      // console.log(time);
      return time.getFullYear()+'.'+[time.getMonth()+1<10?'0'+(time.getMonth()+1):time.getMonth()+1]+'.'+[time.getDate()<10?'0'+time.getDate():time.getDate()]
    }
  },
  methods:{
    editFn:function(){
      // console.log(this.value);
      if(!this.value){
        this.value2=JSON.parse(JSON.stringify(this.value))
      }else{
        this.value2=[...this.value]
      }
    },
    orderFn:function(){
      this.$router.push('/home/OrderManage')
    }
  },
  mounted:function(){
    this.value2=[...this.value]
  }
};
</script>

<style lang="less" scoped>
#ClosingTimeConfiguration > h4 {
  margin-bottom: 30px;
}
.content {
  width: 400px;
  padding: 20px;
  font-size: 14px;
  background: #eee;
}
.content > p {
  padding: 20px 0;
}
.content > .el-button {
  width: 100%;
  margin: 20px 0;
}
.content > div {
  text-align: center;
  color: rgb(197, 48, 48);
  margin: 10px 0;
}
</style>
